const  express = require('express')

const  app = express()

//配置解析表单数据的中间件
app.use(express.urlencoded({ extended: false }))
// app.all('*', function (req, res, next) {
//   res.header('Access-Control-Allow-Origin', '*');
//   res.header('Access-Control-Allow-Headers', 'Content-Type');
//   res.header('Access-Control-Allow-Methods', '*');
//   res.header('Content-Type', 'application/json;charset=utf-8');
//   next();
// });

//跨域要在路由之前设置
const cors =require('cors')
app.use(cors())
//导入路由模块
const router = require('./apiRouter')
//注册
// app.use('api',router)
app.use(router)





app.listen(3000, () => {
  console.log('express server running at http://127.0.0.1');
})